<script>
<?php $__env->startSection('admin.select-ajax'); ?>
    <?php if(isset($ajax)): ?>
        configs = $.extend(configs, {
        ajax: {
            url: "<?php echo e($ajax['url'], false); ?>",
            dataType: 'json',
            delay: 250,
            data: function (params) {
                return {
                    q: params.term,
                    page: params.page
                };
            },
            processResults: function (data, params) {
                params.page = params.page || 1;

                return {
                    results: $.map(data.data, function (d) {
                        d.id = d.<?php echo e($ajax['idField'], false); ?>;
                        d.text = d.<?php echo e($ajax['textField'], false); ?>;
                        return d;
                    }),
                    pagination: {
                        more: data.next_page_url
                    }
                };
            },
            cache: true
        },
        escapeMarkup: function (markup) {
            return markup;
        }
    });
    <?php endif; ?>
<?php $__env->stopSection(true); ?>
</script>

<?php $__env->startSection('admin.select-load'); ?>
    <?php if(isset($load)): ?>
    <script once>
        var selector = '<?php echo $selector; ?>';

        $(document).off('change', selector);
        $(document).on('change', selector, function () {
            var target = $(this).closest('<?php echo e($load['group'] ?? '.fields-group', false); ?>').find(".<?php echo e($load['class'], false); ?>");

            if (String(this.value) !== '0' && ! this.value) {
                return;
            }
            $.ajax("<?php echo e($load['url'], false); ?>?q="+this.value).then(function (data) {
                target.find("option").remove();
                $(target).select2({
                    data: $.map(data, function (d) {
                        d.id = d.<?php echo e($load['idField'], false); ?>;
                        d.text = d.<?php echo e($load['textField'], false); ?>;
                        return d;
                    })
                }).val(target.attr('data-value').split(',')).trigger('change');
            });
        });
        $(selector).trigger('change');
    </script>
    <?php endif; ?>
<?php $__env->stopSection(true); ?>

<?php $__env->startSection('admin.select-lang'); ?>
<?php if(config('app.locale') !== 'en'): ?>
    
    <script once>
        <?php
            $lang = trans('select2');
            $locale = config('app.locale');
        ?>
        if ($.fn.select2) {
            var e = $.fn.select2.amd;

            e.define("select2/i18n/<?php echo e($locale, false); ?>", [], function () {
                return {
                    errorLoading: function () {
                        return "<?php echo e($lang['error_loading'], false); ?>"
                    }, inputTooLong: function (e) {
                        return "<?php echo e($lang['input_too_long'], false); ?>".replace(':num', e.input.length - e.maximum)
                    }, inputTooShort: function (e) {
                        return "<?php echo e($lang['input_too_short'], false); ?>".replace(':num', e.minimum - e.input.length)
                    }, loadingMore: function () {
                        return "<?php echo e($lang['loading_more'], false); ?>"
                    }, maximumSelected: function (e) {
                        return "<?php echo e($lang['maximum_selected'], false); ?>".replace(':num', e.maximum)
                    }, noResults: function () {
                        return "<?php echo e($lang['no_results'], false); ?>"
                    }, searching: function () {
                        return "<?php echo e($lang['searching'], false); ?>"
                    }
                }
            }), {define: e.define, require: e.require}
        }
    </script>
<?php endif; ?>
<?php $__env->stopSection(true); ?><?php /**PATH D:\phpstudy_pro\WWW\www.dcat.loc\vendor\dcat\laravel-admin\src/../resources/views/scripts/select.blade.php ENDPATH**/ ?>